<%@page contentType="text/html; charset=utf-8" language="java" %>
<%@page import="bean.*" %>
<%@page import="biz.*" %>
<%
		String action = request.getParameter("action");
		if(action != null){
			if (action.equals("chvid")){
				boolean flag = ItemBiz.updateCurvid(Integer.parseInt(request.getParameter("vid")));
				if(flag){
					out.print("<script>alert('更新词条版本成功！');history.back();</script>");
				}else{
					out.print("<script>alert('更新失败，请检查版本编号是否正确！');history.back();</script>");
				}
			}else if(action.equals("delvid")){
				boolean flag = ItemBiz.deleteVitems(Integer.parseInt(request.getParameter("vid")));
				if(flag){
					out.print("<script>alert('删除词条版本成功！');history.back();</script>");
				}else{
					out.print("<script>alert('删除词条失败，请检查版本编号是否正确！');history.back();</script>");
				}
			}else if(action.equals("deliid")){
				boolean flag = ItemBiz.deleteItems(Integer.parseInt(request.getParameter("iid")));
				if(flag){
					out.print("<script>alert('删除词条成功！');history.back();</script>");
				}else{
					out.print("<script>alert('删除词条失败，请检查词条ID是否正确！');history.back();</script>");
				}
			}
		}
%>
<html>
<head>
<%
User user = new User();
Search s = new ItemBiz();
if(session.getAttribute("uid") == null){
	out.print("<script>alert('请先登录！');history.back();</script>");
	response.sendRedirect("login.jsp");
}
else
{
	user = UserBiz.getUserByUid(Integer.parseInt(session.getAttribute("uid").toString()));
	if (!user.getTagAdmin()){
		out.print("<script>alert('请以管理员帐号登录本页面！');history.back();</script>");
		response.sendRedirect("login.jsp");
	}
}

%>
	<title><%=user.getUname()%>的词条管理页面</title>
	<link href="css.css" rel="stylesheet" type="text/css">
	</head>
	<body>
	<jsp:include page="/head.jsp"/>
		<center>
		<div id="u_title">
		<div><span id="uname"><%=user.getUname()%>[管理员]</span>&nbsp;
		<a href="mailto:<%=user.getUemail()%>"><%=user.getUemail()%></a></div>
		<span id="uinfo"><%=user.getUinfo()%></span><span id="uid">用户ID-<%=user.getUid()%></span>
		<hr/>
		</div>
		</center>
		<div id="mainpage">
		<div class="leftbar" style="z-index:1;">
		<fieldset class="u_fieldset">
		<legend id="u_legend">词条管理</legend>
		<ul id="left_nav">
        	<li><a href="#chvid">更新词条版本</a></li>
        	<li><a href="#delvid">删除词条版本</a></li>
        	<li><a href="#deliid">删除词条</a></li>
        </ul>
        </fieldset>
		<fieldset class="u_fieldset">
		<legend id="u_legend">用户操作</legend>
		<ul id="left_nav">
        	<li><a href="additem.jsp?l=0&p=0&r=0">创建新词条</a></li>
        	<li><a href="updateuser.jsp">更新账户信息</a></li>
        	<li><a href="logout.jsp">退出登录</a></li>
        	<li><a href="deleteuser.jsp">永久删除账户</a></li>
        </ul>
        </fieldset>
		</div>
		<div class="rightbar">
		<fieldset style="text-align:center;width:650px;" >
			<p class="f_title"><a name="chvid">更新词条版本</a></p>
			<div class="disc">在下方输入要激活的词条版本的编号，然后点击更新。</div>
			<form method="post" action="itemadmin.jsp?action=chvid">
				<ol>
				<li><label for="vid">词条版本编号：</label><span><input type="text" name="vid" class="input" style="width:180px;"></span></li>
				</ol>
				<input type="submit" value="更新" style="width:60px" class="button"/>
			</form>
		</fieldset>
		<fieldset style="text-align:center;width:650px;" >
			<p class="f_title"><a name="delvid">删除词条版本</a></p>
			<div class="disc">在下方输入要删除的词条版本的编号，然后点击删除。</div>
			<form method="post" action="itemadmin.jsp?action=delvid">
				<ol>
				<li><label for="vid">词条版本编号：</label><span><input type="text" name="vid" class="input" style="width:180px;"></span></li>
				</ol>
				<input type="submit" value="删除" style="width:60px" class="button"/>
			</form>
		</fieldset>
		<fieldset style="text-align:center;width:650px;" >
			<p class="f_title"><a name="deliid">删除词条</a></p>
			<div class="disc">在下方输入要删除的词条的ID，然后点击确认。<br/>注意：删除后不可恢复！</div>
			<form method="post" action="itemadmin.jsp?action=deliid">
				<ol>
				<li><label for="iid">词条ID：</label><span><input type="text" name="iid" class="input" style="width:180px;"></span></li>
				</ol>
				<input type="submit" value="删除" style="width:60px" class="button"/>
			</form>
		</fieldset>
		</div>
		</div>
	<jsp:include page="/copyright.html"/>
	</body>
</html>